function res = writeToFile(filename, matrix, n, m)

filename;

fp = fopen(filename, 'w');

if (fp < 0) 
    fprintf(1, 'Errore nell'' apertura del file su cui scrivere');
end

fp;

res = fprintf(fp, '%s\n','Matrix');
for k=1:n
	res = fprintf(fp, '%s','[ ');
	for l=1:m
		res = fprintf(fp, '% 6.5f ', real(matrix(k,l)));
		res = fprintf(fp, '% 6.5fi ', imag(matrix(k,l)));
	end
	
	res = fprintf(fp, '%s\n',' ]');
end
	
res = fprintf(fp, '\n');
res = fclose(fp);
